<?php
// +-----------------+------------------+------+-----+---------+----------------+
// | Field           | Type             | Null | Key | Default | Extra          |
// +-----------------+------------------+------+-----+---------+----------------+
// | id              | int(11)          | NO   | PRI | NULL    | auto_increment |
// | title           | varchar(50)      | NO   |     |         |                |
// | slug            | varchar(50)      | NO   |     |         |                |
// | parent_id       | varchar(255)     | YES  |     | 0       |                |
// | pc_banner_id    | int(11) unsigned | YES  |     | 0       |                |
// | wap_banner_id   | int(11) unsigned | YES  |     | 0       |                |
// | seo_description | varchar(255)     | NO   |     |         |                |
// | seo_keywords    | varchar(255)     | NO   |     |         |                |
// | index_tpl       | varchar(50)      | NO   |     |         |                |
// | read_tpl        | varchar(50)      | NO   |     |         |                |
// | is_applied      | tinyint(1)       | YES  |     | 0       |                |
// | is_subscribe    | tinyint(1)       | YES  |     | 0       |                |
// | status          | tinyint(1)       | YES  |     | 1       |                |
// | sort            | int(11)          | YES  |     | 0       |                |
// | member_id       | int(11) unsigned | YES  |     | 0       |                |
// | create_time     | int(11) unsigned | YES  |     | 0       |                |
// | update_time     | int(11) unsigned | YES  |     | 0       |                |
// | delete_time     | int(11) unsigned | YES  |     | 0       |                |
// | is_attached     | tinyint(1)       | YES  |     | 0       |                |
// | name            | varchar(50)      | YES  |     |         |                |
// +-----------------+------------------+------+-----+---------+----------------+
namespace app\common\validate;

use think\Validate;

class Category extends Validate
{
    protected $rule = [
        "name" => "require|max:50",
        "title" => "require|max:8",
        "slug" => "max:50",
        "seo_description" => "max:200",
        "seo_keywords" => "max:200",
        "index_tpl" => "max:50",
        "read_tpl" => "max:50",
        "parent_id" => "egt:0",
        "pc_banner_id" => "gt:0",
        "wap_banner_id" => "egt:0",
        "member_id" => "egt:0",
    ];

    protected $field = [
        "name" => "英文名",
        "title" => "分类名",
        "slug" => "分类链接名",
        "seo_description" => "SEO描述",
        "seo_keywords" => "SEO关键词",
        "index_tpl" => "列表页模板名",
        "read_tpl" => "详细页模板名",
        "parent_id" => "上级节点ID",
        "pc_banner_id" => "Banner图片",
        "wap_banner_id" => "手机版Banner图片",
        "member_id" => "编辑管理员",
    ];

    protected $message = [
        "name" => "英文名不能为空",
        "name" => "英文名长度不能超过50个字符",
        "title" => "分类名不能为空",
        "title" => "分类名长度不能超过8个字符",
        "slug" => "分类链接名长度不能超过60个字符",
        "seo_description" => "SEO描述长度不能超过200个字符",
        "seo_keywords" => "SEO关键词长度不能超过™200个字符",
        "index_tpl" => "列表页模板名长度不能超过50个字符",
        "read_tpl" => "详细页模板名长度不能超过50个字符",
        "parent_id" => "上级节点不正确",
        "pc_banner_id" => "Banner图片不能为空",
        "wap_banner_id" => "手机版Banner图片不能为空",
        "member_id" => "编辑管理员不正确",
    ];

    protected $scene = [
        // 一级分类（栏目）
        'parent'  =>  ['name', 'title', 'pc_banner_id'],
        // 二级分类（栏目分类）
        'child'  =>  ['title'],
    ];
}